#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=1e6+5;
int n;
char a[Maxn],b[Maxn];
namespace sub1{
	queue<int>h;
	int f[1<<19];
	inline void solve(){
		int ss=0;
		for(int i=1;i<=n;i++)
			ss+=(1<<i-1)*(a[i]-'0');
		h.push(ss);
		memset(f,-1,sizeof f);
		f[ss]=0;
		while(h.size()){
			int s=h.front();
			h.pop();
			for(int l=1;l<=n;l++){
				int s1=s;
				for(int r=l;r<=n;r++){
					s1^=(1<<r-1);
					if(f[s1]==-1)f[s1]=f[s]+1,h.push(s1);
				}
			}
			for(int l=1;l<=n;l++){
				int s1=s;
				for(int r=l;r<=n;r++){
					if(s1&(1<<r-1))s1-=(1<<r-1);
					if(f[s1]==-1)f[s1]=f[s]+1,h.push(s1);
				}
			}
			for(int l=1;l<=n;l++){
				int s1=s;
				for(int r=l;r<=n;r++){
					if(s1&(1<<r-1));
					else s1+=(1<<r-1);
					if(f[s1]==-1)f[s1]=f[s]+1,h.push(s1);
				}
			}
		}
		ss=0;
		for(int i=1;i<=n;i++)
			ss+=(1<<i-1)*(b[i]-'0');
		printf("%d\n",f[ss]);
	}
}
signed main(){
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	freopen("hard.in","r",stdin);
	freopen("hard.out","w",stdout);
	n=read();
	scanf("%s",a+1);scanf("%s",b+1);
	if(n<=18)sub1::solve();
	int cnt=0,cnt1=0;
	b[n+1]='-';
	for(int i=1;i<=n;i++){
		if(b[i]!=b[i+1]){
			if(b[i]=='1')cnt++;
			else cnt1++;
		}
	}
	printf("%d\n",min(cnt1,1+cnt));
	
	return 0;
}

